package com.loc.dao;

import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

public class BaseDao extends JdbcTemplate {
	
	private DataSource dataSource;
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
		super.setDataSource(dataSource);
	}
	public List<Map<String,Object>> queryForListPage(String sql, int startRow, int rowsCount)
			throws DataAccessException {
		return queryForListPage(sql, startRow, rowsCount,getColumnMapRowMapper());
	}

	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> queryForListPage(String sql, int startRow, int rowsCount,
			RowMapper rowMapper) throws DataAccessException {
		return (List) query(sql, new SplitPageResultSetExtractor(rowMapper,startRow, rowsCount));
	}
}
